<?php

class re_input_validation
{
	protected $type;
	protected $arguments;
	
	protected $regularExpressions = array(
		'require' => '/^[.]+$/',
		'email' => '/^([*+!.\'\\%\/0-9a-z^_`{}=?~:-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i',
		'max' => '/^(.{0,%})$/',
		'min' => '/^(.{1,%})$/',
		'range' => '/^(.{%,%})$/',
		'alpha' => '/^[A-Za-z]*$/',
		'numeric' => '/^[0-9]*$/',
		'alphanumeric' => '/^[A-Za-z0-9]*$/',
		'regex' => '%'
	);
	
	public function __construct($type, $arguments=null)
	{
		$this->type = $type;
		$this->arguments = $arguments;
	}
	
	public function check($value)
	{
		return preg_match($this->regularExpressions[$this->type], $value, $matches);
	}
}

?>